#!/usr/bin/env sh

# Check if running in Windows
if [ -n "$COMSPEC" ]; then
    # Windows section - Execute directly with PowerShell
    powershell -NoProfile -Command "
        if (Get-Command powershell -ErrorAction SilentlyContinue) {
            Write-Host 'PowerShell found, executing pre-commit.ps1...'
            powershell -ExecutionPolicy Bypass -File '.githooks\pre-commit.ps1'
            exit $LASTEXITCODE
        } else {
            Write-Host 'Error: PowerShell is not available. Please install PowerShell.'
            exit 1
        }
    "
    echo "Exiting with status $?"
    exit $?
else
    # Unix-like system section
    echo "Unix-like system found, executing pre-commit.sh..."
    sh .githooks/pre-commit.sh
    echo "Exiting with status $?"
    exit $?
fi
